package com.wk.springbootlearn.common.model;

import lombok.Data;
import net.sf.jsqlparser.expression.DateTimeLiteralExpression;
import org.springframework.data.annotation.Id;
import org.springframework.data.mongodb.core.mapping.Document;

import java.sql.Timestamp;
import java.util.Arrays;
import java.util.Date;

@Data
@Document
public class CommonLog {
    @Id
    private String id;
    private String httpMethod;
    private String url;
    private String ip;
    private int errorCode;
    private String errorMsg;
    private String errorDetail;
    private String errorTrace;
    private Date createTime = new Date();

    public CommonLog setHttpMethod(String httpMethod) {
        this.httpMethod = httpMethod;
        return this;
    }

    public CommonLog setUrl(String url) {
        this.url = url;
        return this;
    }

    public CommonLog setIp(String ip) {
        this.ip = ip;
        return this;
    }

    public CommonLog setErrorCode(int errorCode) {
        this.errorCode = errorCode;
        return this;
    }

    public CommonLog setErrorMsg(String errorMsg) {
        this.errorMsg = errorMsg;
        return this;
    }

    public CommonLog setErrorDetail(String errorDetail) {
        this.errorDetail = errorDetail;
        return this;
    }

    public CommonLog setErrorTrace(String errorTrace) {
        this.errorTrace = errorTrace;
        return this;
    }

    public String toString() {
        return "HTTP_METHOD: "+ this.httpMethod + "; URI: " + this.url + "; IP: " + this.ip + "; ERROR_CODE: " + this.errorCode + "; ERROR_MSG: " + this.errorMsg + "; ERROR_DETAIL: " + this.errorDetail + "; ERROR_TRACE: " + this.errorTrace + ";";
    }
}
